package com.toxictest.testproject.core;

import static playn.core.PlayN.*;

import java.util.ArrayList;
import java.util.List;

import playn.core.GroupLayer;

public class Triangle extends AbstractShape {
	
	private List<Quad> shape= new ArrayList<Quad>(3);
	
	public Triangle(final GroupLayer shapeLayer) {
		Quad quad1= new Quad();
		Quad quad2= new Quad();
		Quad quad3= new Quad();
		shape.add(quad1);
		shape.add(quad2);
		shape.add(quad3);
		layer = graphics().createGroupLayer();
		layer.setOrigin(Quad.getSIDE(), Quad.getSIDE());
		layer.setTranslation(location[0],location[1]);
		layer.addAt(quad1.getImage(), 0, 0);
		layer.addAt(quad2.getImage(), 0, Quad.getSIDE());
		layer.addAt(quad3.getImage(), Quad.getSIDE(), Quad.getSIDE());
		setHeight(Quad.getSIDE()<<1);
		setWidth(Quad.getSIDE()<<1);
		shapeLayer.add(layer);
	}

	public float[][] getTopLine() {
		float[][] topLine=null;
		if ( (int) ( angle % ((2f)*java.lang.Math.PI) ) == 0) {
			topLine = new float[4][2];
			topLine[0][0]=(location[0]-width/2);
			topLine[0][1]=(location[1]-height/2);
			topLine[1][0]=(location[0]);
			topLine[1][1]=(location[1]-height/2);
			topLine[2][0]=(location[0]);
			topLine[2][1]=(location[1]);
			topLine[3][0]=(location[0]+width/2);
			topLine[3][1]=(location[1]);
		}
		else if ( (int) ( angle % ((1f)*java.lang.Math.PI) ) == 0) {
			topLine = new float[2][2];
			topLine[0][0]=(location[0]-width/2);
			topLine[0][1]=(location[1]-height/2);
			topLine[1][0]=(location[0]+width/2);
			topLine[1][1]=(location[1]-height/2);
		}
		else if ( (int) ( angle % ((1.5f)*java.lang.Math.PI) ) == 0) {
			topLine = new float[4][2];
			topLine[0][0]=(location[0]-width/2);
			topLine[0][1]=(location[1]);
			topLine[1][0]=(location[0]);
			topLine[1][1]=(location[1]);
			topLine[2][0]=(location[0]);
			topLine[2][1]=(location[1]+height/2);
			topLine[3][0]=(location[0]+width/2);
			topLine[3][1]=(location[1]-height/2);
		}
		else if ( (int) ( angle % ((0.5f)*java.lang.Math.PI) ) == 0) {
			topLine = new float[2][2];
			topLine[0][0]=(location[0]-width/2);
			topLine[0][1]=(location[1]-height/2);
			topLine[1][0]=(location[0]+width/2);
			topLine[1][1]=(location[1]-height/2);
		}
		return topLine;
	}

	public float[][] getBottomLine() {
		float[][] bottomLine = null;
		if ( (int) ( angle % ((2f)*java.lang.Math.PI) ) == 0) {
			bottomLine = new float[2][2];
			bottomLine[0][0]=(location[0]-width/2);
			bottomLine[0][1]=(location[1]+height/2);
			bottomLine[1][0]=(location[0]+width/2);
			bottomLine[1][1]=(location[1]+height/2);
		}
		else if ( (int) ( angle % ((1f)*java.lang.Math.PI) ) == 0) {
			bottomLine = new float[4][2];
			bottomLine[0][0]=(location[0]-width/2);
			bottomLine[0][1]=(location[1]);
			bottomLine[1][0]=(location[0]);
			bottomLine[1][1]=(location[1]);
			bottomLine[2][0]=(location[0]);
			bottomLine[2][1]=(location[1]+height/2);
			bottomLine[3][0]=(location[0]+width/2);
			bottomLine[3][1]=(location[1]+height/2);
		}
		else if ( (int) ( angle % ((1.5f)*java.lang.Math.PI) ) == 0) {
			bottomLine = new float[2][2];
			bottomLine[0][0]=(location[0]-width/2);
			bottomLine[0][1]=(location[1]+height/2);
			bottomLine[1][0]=(location[0]+width/2);
			bottomLine[1][1]=(location[1]+height/2);
		}
		else if ( (int) ( angle % ((0.5f)*java.lang.Math.PI) ) == 0) {
			bottomLine = new float[4][2];
			bottomLine[0][0]=(location[0]-width/2);
			bottomLine[0][1]=(location[1]+height/2);
			bottomLine[1][0]=(location[0]);
			bottomLine[1][1]=(location[1]+height/2);
			bottomLine[2][0]=(location[0]);
			bottomLine[2][1]=(location[1]);
			bottomLine[3][0]=(location[0]+width/2);
			bottomLine[3][1]=(location[1]);
		}
		return bottomLine;
	}

}
